<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>mseek</title>
  </head>
  <body bgcolor="#FFFFFF">
    <center>Scilab Function</center>
    <div align="right">Last update : 01/04/2004</div>
    <p>
      <b>mseek</b> -  set current position in binary file.  </p>
    <h3>
      <font color="blue">Calling Sequence</font>
    </h3>
    <dl>
      <dd>
        <tt>mseek(n [,fd, flag])       </tt>
      </dd>
    </dl>
    <h3>
      <font color="blue">Parameters</font>
    </h3>
    <ul>
      <li>
        <tt>
          <b>n</b>
        </tt>:a positive scalar: The offset from origin in number of bytes.</li>
      <li>
        <tt>
          <b>fd</b>
        </tt>: scalar. The <tt>
          <b>fd</b>
        </tt> parameter returned by the function <tt>
          <b>mopen</b>
        </tt>. -1 stands for last opened file. Default value is -1.</li>
      <li>
        <tt>
          <b>flag</b>
        </tt>: a string. specifies the origin. Default value 'set'.</li>
    </ul>
    <h3>
      <font color="blue">Description</font>
    </h3>
    <p>
    The function <tt>
        <b>mseek()</b>
      </tt> sets the position of the next input or output operation
    on  the stream <tt>
        <b>fd</b>
      </tt>. The new position is at
    the signed distance given by <tt>
        <b>n</b>
      </tt> bytes from  the  beginning,  from
    the current position, or from the end of the file, according  to the 
    <tt>
        <b>flag</b>
      </tt> value which can be <tt>
        <b>'set'</b>
      </tt>, <tt>
        <b>'cur'</b>
      </tt> or <tt>
        <b>'end'</b>
      </tt>.</p>
    <p>
      <tt>
        <b>mseek()</b>
      </tt> allows the file position indicator to be set  beyond
    the  end of the existing data in the file.  If data is later
    written at this point, subsequent reads of data in  the  gap
    will  return  zero  until  data is actually written into the
    gap.  <tt>
        <b>mseek()</b>
      </tt>, by itself, does not extend the  size  of  the
    file.</p>
    <h3>
      <font color="blue">Examples</font>
    </h3>
    <pre>

file3='test3.bin'
fd1= mopen(file3,'wb');
for i=1:10, mput(i,'d'); end 
mseek(0);
mput(678,'d');
mseek(0,fd1,'end');
mput(932,'d');
mclose(fd1)
fd1= mopen(file3,'rb');
res=mget(11,'d')
res1=[1:11]; res1(1)=678;res1($)=932;
if res1&lt;&gt;res ;write(%io(2),'Bug');end;
mseek(0,fd1,'set');
// trying to read more than stored data 
res1=mget(100,'d',fd1);
if res1&lt;&gt;res ;write(%io(2),'Bug');end;
meof(fd1)
mclearerr(fd1)
mclose(fd1);
 
  </pre>
    <h3>
      <font color="blue">See Also</font>
    </h3>
    <p>
      <a href="mclose.htm">
        <tt>
          <b>mclose</b>
        </tt>
      </a>,&nbsp;&nbsp;<a href="meof.htm">
        <tt>
          <b>meof</b>
        </tt>
      </a>,&nbsp;&nbsp;<a href="mprintf.htm">
        <tt>
          <b>mfprintf</b>
        </tt>
      </a>,&nbsp;&nbsp;<a href="fprintfMat.htm">
        <tt>
          <b>fprintfMat</b>
        </tt>
      </a>,&nbsp;&nbsp;<a href="mfscanf.htm">
        <tt>
          <b>mfscanf</b>
        </tt>
      </a>,&nbsp;&nbsp;<a href="fscanfMat.htm">
        <tt>
          <b>fscanfMat</b>
        </tt>
      </a>,&nbsp;&nbsp;<a href="mget.htm">
        <tt>
          <b>mget</b>
        </tt>
      </a>,&nbsp;&nbsp;<a href="mgetstr.htm">
        <tt>
          <b>mgetstr</b>
        </tt>
      </a>,&nbsp;&nbsp;<a href="mopen.htm">
        <tt>
          <b>mopen</b>
        </tt>
      </a>,&nbsp;&nbsp;<a href="mprintf.htm">
        <tt>
          <b>mprintf</b>
        </tt>
      </a>,&nbsp;&nbsp;<a href="mput.htm">
        <tt>
          <b>mput</b>
        </tt>
      </a>,&nbsp;&nbsp;<a href="mputstr.htm">
        <tt>
          <b>mputstr</b>
        </tt>
      </a>,&nbsp;&nbsp;<a href="mfscanf.htm">
        <tt>
          <b>mscanf</b>
        </tt>
      </a>,&nbsp;&nbsp;<a href="mseek.htm">
        <tt>
          <b>mseek</b>
        </tt>
      </a>,&nbsp;&nbsp;<a href="mtell.htm">
        <tt>
          <b>mtell</b>
        </tt>
      </a>,&nbsp;&nbsp;<a href="mdelete.htm">
        <tt>
          <b>mdelete</b>
        </tt>
      </a>,&nbsp;&nbsp;</p>
  </body>
</html>
